from django.db import models

# Create your models here.


class User(models.Model):

    username = models.CharField(max_length=16,unique=True,verbose_name='用户名')
    password = models.CharField(max_length=16,verbose_name='密码')

    def __str__(self):
        return self.username

class Item(models.Model):

    statuschoices = [('available','available'),('sold','sold')]
    title = models.CharField(verbose_name='标题',null=False,max_length=255)
    price = models.DecimalField(max_digits=10,decimal_places=2,null=False)
    seller_id = models.ForeignKey(User,on_delete=models.CASCADE,related_name='user')
    status = models.CharField(choices=statuschoices,verbose_name='状态',default='available')

    def __str__(self):
        return self.title
